macro 'Make Movie to DiskÉ';{Captures images at a specified rate and saves them to disk.Select an area of interest within the Camera window beforestarting. Abort at any time by pressing the mouse button.}var  nFrames,n,Left,Top,Width,Height:integer;  interval,EndTicks,secs:integer;  FirstTime:boolean;begin  GetRoi(Left,Top,Width,Height);  if width=0 then begin     PutMessage('First select the area of interest in the Camera window.');     exit;  end;  nFrames:=GetNumber('Number of Frames?',10);  secs:=GetNumber ('Delay Between Frames (seconds)?',60.0);  interval:=round(secs*60);  FirstTime:=true;  for n:=1 to nFrames do begin     StopCapturing;  beep;     MakeRoi(Left,Top,Width,Height);     SaveAs('Frame ',n);     if FirstTime then begin        EndTicks:=TickCount+interval;        FirstTime:=false;     end;     if button then begin        StopCapturing;        exit;     end;     StartCapturing;     while TickCount<EndTicks do begin         secs:=(EndTicks-TickCount) div 60;         ShowMessage(n:1,'/',nFrames,' ',secs:4)     end;     EndTicks:=EndTicks+interval;  end;  StopCapturing;end;macro 'Make AV Time-lapse MovieÉ';{Captures a sequence of images to disk using the "Plug-in Digitizer"in "Faceless" mode. Abort by pressing the mouse button.}var  nFrames, n, pid:integer;  interval, StartTicks, EndTicks:integer;  time:real;  path:string;begin  Requiresversion(1.55);  SaveState;  path:=getString('Folder path:','hd400:movie');  nFrames:=GetNumber('Number of Frames?',10);  time:=GetNumber ('Delay Between Frames (seconds)?',60.0);  interval:=round(time*60);  StartTicks:=TickCount;  EndTicks:=TickCount+interval;  for n:=1 to nFrames do begin     time:=(TickCount-StartTicks)/ 60;     ShowMessage('frame: ', n:1,' \time: ',time:1:2);     Acquire('Plug-in Digitizer');     pid:=PidNumber;     SelectPic(pid);     SetForegroundColor(255);     SetFont('Monaco');     SetFontSize(9);     MoveTo(2,7);     write(n:3,'  ',time:4:2);     SaveAs(path,':Frame ',n);     while TickCount<EndTicks do begin        if button then exit;     end;     EndTicks:=EndTicks+interval;     Dispose;  end;  RestoreState;end;macro 'Capture Averaged to StackÉ';var  x,y,i,s,f,t,width,height:integer;  camera, stack, avg, nFrames:integer;begin  nFrames:=GetNumber('Number of frames to capture:', 10);  SelectWindow('Camera');  camera:=PidNumber;  GetRoi(x,y,width,height);   if width=0 then begin    PutMessage('Rectangular selection required.');    exit;  end;  SetNewSize(width,height);  MakeNewStack('Stack');  stack:=PidNumber;  s:=TickCount;  for i:= 1 to nFrames do begin     ChoosePic(Camera);     MakeRoi(x,y,width,height);     AverageFrames;     RestoreRoi;     Copy;     ChoosePic(stack);     if i>1 then AddSlice;     Paste;  end;  f:=TickCount;  KillRoi;  SelectSlice(1);  t:=(f-s)/60;  ShowMessage('Time = ', t:1:2, ' seconds');  exit;  AverageSlices;  avg:=PidNumber;  SelectPic(stack);  Dispose;  SelectPic(avg);end;procedure PlotFrameIntervals(nFrames: integer);var   xmin,xmax,ymin,ymax,i,xscale,yscale,yscale2:real;   width,height,margin,pwidth,pheight:integer;   x,y,pbottom,yinc:integer;   minInterval,maxInterval,offset:real;   interval,reqInterval,avgInterval,ElapsedTime:real;   TotalTime:real;begin  RequiresVersion(1.58);  SaveState;  margin:=40;  width:=500;  height:=300;  ymin:=999999;  ymax:=-999999;  ElapsedTime := PlotData[nFrames];  reqInterval := PlotData[nFrames+1];  avgInterval := ElapsedTime / (nFrames -1);  TotalTime := avgInterval * nFrames;  for i:=1 to nFrames -1 do begin      interval := PlotData[i+1]-PlotData[i];      if interval<ymin then ymin:=interval;      if interval>ymax then ymax:=interval;  end;  minInterval:=ymin;  maxInterval:=ymax;  ymin:=0;  xmin:=1;  xmax:=nFrames-1;  SetNewSize(width,height);  SetForeground(255);  SetBackground(0);  MakeNewWindow('Frame Intervals (seconds)');  pwidth:=width-margin-130;  pheight:=height-2*margin;  pbottom:=margin+pheight;  xscale:=pwidth/xmax;  yscale:=pheight/ymax;  yscale2:=pheight/(PlotData[nFrames]);  SetForeground(255);  SetBackground(0);   SetLineWidth(1);  for i:=2 to nFrames do begin     interval := PlotData[i]-PlotData[i-1];     x:=margin+(i-1)*xscale;     y:=pbottom-interval*yscale;     MoveTo(x, pBottom);     LineTo(x,y);     MoveTo(margin+(i-2)*xscale, pBottom-(PlotData[i-1])*yscale2);     LineTo(margin+(i-1)*xscale, pBottom-(PlotData[i])*yscale2);  end;  KillRoi;  MoveTo(margin, margin);  LineTo(margin, margin+pheight);  LineTo(margin+pwidth, margin+pheight);  SetFont('Geneva');  SetFontSize(9);  SetText('Right Justified');  MoveTo(margin-2, margin+pheight-5);  writeln(ymin:1:3);  MoveTo(margin-2, margin);  writeln(ymax:1:3);  SetText('Left Justified');  x := margin+pwidth+10;  y := margin;  yinc := 12;  MoveTo(x, y);  writeln('frames=', nFrames:1);  y := y+yinc;  MoveTo(x, y);  writeln('expected time=', nFrames*reqInterval:1:4);  y := y+yinc;  MoveTo(x, y);  writeln('actual time=', TotalTime:1:4);  y := y+yinc;  MoveTo(x, y);  writeln('req. interval=', reqInterval:1:4);  y := y+yinc;  MoveTo(x, y);  writeln('avg interval=', avgInterval:1:4);  y := y+yinc;  MoveTo(x, y);  writeln('min interval=', minInterval:1:4);  y := y+yinc;  MoveTo(x, y);  writeln('max interval=', maxInterval:1:4);  y := y+yinc;  MoveTo(x, y);  if reqInterval <> 0.0 then     writeln('expected rate=', 1/reqInterval:1:3,' fps');  y := y+yinc;  MoveTo(x, y);  writeln('actual rate=', (nFrames)/TotalTime:1:3,' fps'); RestoreState;end;macro 'Make Movie and Plot Intervals [M]';var  i, nFrames, x, y, w, h: integer;  avgInterval: real;begin  GetRoi(x, y, w, h);  if w = 0 then begin     PutMessage('Selection Required.');     exit;  end;  MakeMovie('dialog, time-stamp', -1, -1);  nFrames := PlotData[0];  PlotFrameIntervals(nFrames); end;Macro 'Frame Rate vs. Frame Size';var  n, i, width, height,w,h:integer;  avgFrameInterval: real;begin   n := 50;   StartCapturing;   GetPicSize(width, height);   SetFont('Monaco');   SetFontSize(9);   NewTextWindow('Rate vs. Size', 150, 400);   MoveWindow(750, 50);   SaveState;   for i := 1 to n do begin     SelectWindow('Camera');     w := round(width*(i/n));      h := round(height*(i/n));      w := w - (w mod 4);      h := h - (h mod 4);     MakeRoi(0, 0, w, h);     MakeMovie('blind', 10, 0);     avgFrameInterval := GetSliceSpacing;     Dispose;     SelectWindow('Rate vs. Size');     writeln(i:3, avgFrameInterval:6:3, '  ', w:1:0, 'x', h:1:0 );  end;  RestoreState;end;macro 'Projection Example';begin   SetProjection('Initial Angle', 0);   SetProjection('Total Rotation', 360);   SetProjection('Rotation Increment', 30);   SetDensitySlice(0, 254);   {sets transparency bounds}   SetProjection('Surface Opacity', 50);   SetProjection('Surface Depth-Cueing', 50);   SetProjection('Interior Depth-Cueing', 50);   SetProjection('Save Projections', false);   SetProjection('Minimize Size', true);   SetProjection('Y-Axis');   SetProjection('Brightest Point');   Project; {Dialog is not displayed}end.